﻿<ViewDataFormTemplateSpec 
	xmlns="bb_appfx_viewdataformtemplate" 
	xmlns:common="bb_appfx_commontypes" 
	ID="4528f27d-a263-4b4b-ba01-c5d734b1af14" 
	Name="Constituent Basic Info"
	Description="Constituent Record with code translations"
	Author="Blackbaud Professional Services"
	DataFormInstanceID="0346332e-336e-43f4-b836-a718dfe83e2e" 
	RecordType="Constituent"
	common:SecurityUIFolder="Service Bus Adapter"
	>

	<!-- define the SP that returns the data used by the form -->
	<SPDataForm SPName="USP_DATAFORMTEMPLATE_VIEW_CONSTITUENTBASICINFO">
		<common:CreateProcedureSQL>
			<![CDATA[
create procedure dbo.USP_DATAFORMTEMPLATE_VIEW_CONSTITUENTBASICINFO
(
	@ID uniqueidentifier,
	@DATALOADED bit = 0 output,
	@KEYNAME nvarchar(100) = null output,
  @FIRSTNAME nvarchar(50) = null output,
  @MIDDLENAME           nvarchar(50) = null                   output,
  @MAIDENNAME           nvarchar(100) = null                  output,
  @NICKNAME             nvarchar(50) = null                   output,
  @THELOOKUPID          nvarchar(100) = null                  output,
  @SSN                  nvarchar(4000) = null                 output,
  @TITLE                nvarchar(100) = null                  output,
  @TITLECODEID          uniqueidentifier = null               output,
  @SUFFIX               nvarchar(100) = null                  output,
  @SUFFIXCODEID         uniqueidentifier = null               output, 
  @GENDERCODE           tinyint = null                        output,
  @BIRTHDATE            char(8) = null                        output,
  @ISINACTIVE           bit = null                            output,
  @WEBADDRESS           nvarchar(2047) = null                 output,
  @ISORGANIZATION       bit = null                            output,
  @MARITALSTATUS        nvarchar(100) = null                  output,
  @MARITALSTATUSCODEID  uniqueidentifier = null               output, 
  @CUSTOMIDENTIFIER     nvarchar(100) = null                  output,
  @CHANGEDBYID          uniqueidentifier = null               output, 
  @CHANGEDBYUSERNAME    nvarchar(128) = null                  output,
  @DATEADDED            datetime = null                       output,
  @DATECHANGED          datetime = null                       output,
  @GENDER               nvarchar(7) = null                    output,
  @ISCONSTITUENT        bit = null                            output,
  @AGE                  int = null                            output,
  @TITLE2               nvarchar(100) = null                  output,
  @TITLE2CODEID         uniqueidentifier = null               output
)
as
	set nocount on;
	
	-- be sure to set this, in case the select returns no rows
	set @DATALOADED = 0;
	
	-- populate the output parameters, which correspond to fields on the form.  Note that
	-- we set @DATALOADED = 1 to indicate that the load was successful.  Otherwise, the system
	-- will display a "no data loaded" message.
	select @DATALOADED = 1,
	  @KEYNAME = c.KEYNAME, 
    @FIRSTNAME = c.FIRSTNAME, 
    @MIDDLENAME           = c.MIDDLENAME, 
    @MAIDENNAME           = c.MAIDENNAME, 
    @NICKNAME             = c.NICKNAME,
    @THELOOKUPID          = c.LOOKUPID,
    @SSN                  = '', --c.SSN, (SSN messes up XML output!)
    @TITLE                = COALESCE(t.DESCRIPTION, ''), 
    @TITLECODEID          = c.TITLECODEID, 
    @TITLE2                = COALESCE(t2.DESCRIPTION, ''), 
    @TITLE2CODEID          = c.TITLE2CODEID, 
    @SUFFIX               = COALESCE(s.DESCRIPTION, ''), 
    @SUFFIXCODEID         = c.SUFFIXCODEID, 
    @GENDERCODE           = c.GENDERCODE, 
    @BIRTHDATE            = c.BIRTHDATE, 
    @ISINACTIVE           = c.ISINACTIVE, 
    @WEBADDRESS           = c.WEBADDRESS, 
    @ISORGANIZATION       = c.ISORGANIZATION, 
    @MARITALSTATUS        = COALESCE(m.DESCRIPTION, ''), 
    @MARITALSTATUSCODEID  = c.MARITALSTATUSCODEID,
    @CUSTOMIDENTIFIER     = c.CUSTOMIDENTIFIER, 
    @CHANGEDBYID          = c.CHANGEDBYID, 
    @CHANGEDBYUSERNAME    = COALESCE(ca.USERNAME, ''),
    @DATEADDED            = c.DATEADDED, 
    @DATECHANGED          = c.DATECHANGED, 
    @GENDER               = c.GENDER, 
    @ISCONSTITUENT        = c.ISCONSTITUENT, 
    @AGE                  = c.AGE

       
  FROM CONSTITUENT c
    LEFT JOIN TITLECODE         t   ON c.TITLECODEID          = t.ID
    LEFT JOIN TITLECODE         t2   ON c.TITLE2CODEID          = t2.ID
    LEFT JOIN SUFFIXCODE        s   ON c.SUFFIXCODEID         = s.ID
    LEFT JOIN MARITALSTATUSCODE m   ON c.MARITALSTATUSCODEID  = m.ID
    LEFT OUTER JOIN CHANGEAGENT ca  ON ca.ID                  = c.CHANGEDBYID
    
	where c.ID = @ID
	
	return 0;
			]]>
		</common:CreateProcedureSQL>
	</SPDataForm>

	<!-- describe fields on the form, which correspond to parameters on the SP.  Note that system paramters 
	like the context @ID, @DATALOADED, and @CURRENTAPPUSERID need not be listed. -->
	<common:FormMetaData FixedDialog="true">
		<common:FormFields>
      <common:FormField FieldID="KEYNAME" Caption="KEYNAME" DataType="String" MaxLength="100" />
			<common:FormField FieldID="FIRSTNAME" Caption="FIRSTNAME" DataType="String" MaxLength="50" />
      <common:FormField FieldID="MIDDLENAME"          Caption="MIDDLENAME"          DataType="String" MaxLength="50" />
      <common:FormField FieldID="MAIDENNAME"          Caption="MAIDENNAME"          DataType="String" MaxLength="100" />
      <common:FormField FieldID="NICKNAME"            Caption="NICKNAME"            DataType="String" MaxLength="50" />
      <common:FormField FieldID="THELOOKUPID"            Caption="THELOOKUPID"            DataType="String" MaxLength="100" />
      <common:FormField FieldID="SSN"                 Caption="SSN"                 DataType="String" MaxLength="4000" />
      <common:FormField FieldID="TITLE"               Caption="TITLE"               DataType="String" MaxLength="100" />
      <common:FormField FieldID="TITLECODEID"         Caption="TITLECODEID"         DataType="Guid" />
      <common:FormField FieldID="SUFFIX"              Caption="SUFFIX"              DataType="String" MaxLength="100" />
      <common:FormField FieldID="SUFFIXCODEID"        Caption="SUFFIXCODEID"        DataType="Guid" />
      <common:FormField FieldID="GENDERCODE"          Caption="GENDERCODE"          DataType="TinyInt" />
      <common:FormField FieldID="BIRTHDATE"           Caption="BIRTHDATE"           DataType="String" MaxLength="8" />
      <common:FormField FieldID="ISINACTIVE"          Caption="ISINACTIVE"          DataType="String" MaxLength="10" />
      <common:FormField FieldID="WEBADDRESS"          Caption="WEBADDRESS"          DataType="String" MaxLength="2047" />
      <common:FormField FieldID="ISORGANIZATION"      Caption="ISORGANIZATION"      DataType="Boolean" MaxLength="10" />
      <common:FormField FieldID="MARITALSTATUS"       Caption="MARITALSTATUS"       DataType="String" MaxLength="100" />
      <common:FormField FieldID="MARITALSTATUSCODEID" Caption="MARITALSTATUSCODEID" DataType="String" MaxLength="10" />
      <common:FormField FieldID="CUSTOMIDENTIFIER"    Caption="CUSTOMIDENTIFIER"    DataType="String" MaxLength="100" />
      <common:FormField FieldID="CHANGEDBYID"         Caption="CHANGEDBYID"         DataType="Guid" />
      <common:FormField FieldID="CHANGEDBYUSERNAME"   Caption="CHANGEDBYUSERNAME"   DataType="String" MaxLength="128" />
      <common:FormField FieldID="DATEADDED"           Caption="DATEADDED"           DataType="Date" />
      <common:FormField FieldID="DATECHANGED"         Caption="DATECHANGED"         DataType="Date" />
      <common:FormField FieldID="GENDER"              Caption="GENDER"              DataType="String" MaxLength="7" />
      <common:FormField FieldID="ISCONSTITUENT"       Caption="ISCONSTITUENT"       DataType="Boolean" />
      <common:FormField FieldID="AGE"                 Caption="AGE"                 DataType="Integer" />
      <common:FormField FieldID="TITLE2"               Caption="TITLE2"               DataType="String" MaxLength="100" />
      <common:FormField FieldID="TITLE2CODEID"         Caption="TITLE2CODEID2"         DataType="Guid" />
  </common:FormFields>
	</common:FormMetaData>

</ViewDataFormTemplateSpec>